/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.stemaini.utility;

import java.sql.*;

/**
 *
 * @author Administrator
 */
public class koneksi_1
{
    //Koneksi
    //Hal yang sangat perlu diingat untuk membuat database dalam MySQL
    String koneksi = "org.gjt.mm.mysql.Driver";
    String database = "jdbc:mysql://localhost:3306/taini";
    String user = "root";
    String password = "";

    public koneksi_1()
    {

    }

    public void insertTbData_Korpus(String judul, String isi)
    {
            try
            {
                Class.forName(koneksi);
                Connection connection = DriverManager.getConnection(database,user,password);
                Statement statement = connection.createStatement();

                String sql = "insert into DOKUMEN (judul,isi) values ('"+judul+"','"+isi+"');";

                statement.executeUpdate(sql);
                statement.close();
                connection.close();

                System.out.println("Data telah disimpan");                  
            }
            catch(Exception e)
            {}
     }

    public void insertTb_kamus(String kata)
    {
            try
            {
                Class.forName(koneksi);
                Connection connection = DriverManager.getConnection(database,user,password);
                Statement statement = connection.createStatement();
                String sql = "insert into kamus (kata) values ('"+kata+"');";

                statement.executeUpdate(sql);
                statement.close();
                connection.close();

                System.out.println("Data telah disimpan");
            }
            catch(Exception e)
            {

            }
     }

    public void insertTb_StopList(String stopword)
    {
        try
        {
            Class.forName(koneksi);
            Connection connection = DriverManager.getConnection(database,user,password);
            Statement statement = connection.createStatement();
            String sql = "insert into stoplist (stopword) values ('"+stopword+"');";

            statement.executeUpdate(sql);
            statement.close();
            connection.close();

            System.out.println("Data telah disimpan");
        }
        catch(Exception e)
        {

        }
     }

     public void DeleteAllTbData_kamus()
     {
        try
        {
            Class.forName(koneksi);
            Connection connection = DriverManager.getConnection(database,user,password);
            Statement statement = connection.createStatement();
            String sql = "TRUNCATE TABLE `kamus`";

            statement.executeUpdate(sql);
            statement.close();
            connection.close();

            System.out.println("Semua Data telah dihilangkan");
        }
        catch(Exception e)
        {

        }
     }

     public void DeleteAllTbData_StopList()
     {
        try
        {
            Class.forName(koneksi);
            Connection connection = DriverManager.getConnection(database,user,password);
            Statement statement = connection.createStatement();
            String sql = "TRUNCATE TABLE `stoplist`";

            statement.executeUpdate(sql);
            statement.close();
            connection.close();

            System.out.println("Semua Data telah dihilangkan");
        }
        catch(Exception e)
        {

        }
     }


     public void DeleteAllTbData_Korpus()
     {
            try
            {
                Class.forName(koneksi);
                Connection connection = DriverManager.getConnection(database,user,password);
                Statement statement = connection.createStatement();
                String sql = "TRUNCATE TABLE `DOKUMEN`";

                statement.executeUpdate(sql);
                statement.close();
                connection.close();

                System.out.println("Semua Data telah dihilangkan");
            }
            catch(Exception e)
            {

            }
     }

    private void clear()
    {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
